;(function($){

    /* Display Loader when page load
    =========================================*/
    $(window).load(function() {
        $(".loader").fadeOut(2000);
    }); 

    /* Nicescroll
    =========================================*/
	$('.header').niceScroll({
		railalign: 'left'
	});
	
	$('html').niceScroll({
        cursorwidth: '10px',
        cursorborderradius: '0px'
    });	

    /* One Page Navigation
    =========================================*/
	/*
    $('.nav').onePageNav({
        currentClass: 'current',
        changeHash: false,
        scrollSpeed: 1200,
        scrollOffset: 0,
        scrollThreshold: 0.5,
        filter: ':not(.external)',
        easing: 'easeOutBack',
    });	
    */

    /* Box Preview Image by PrettyPhoto
    =========================================*/
    $("a[data-rel^='prettyPhoto']").prettyPhoto({
        social_tools: false,
        theme: 'facebook'
    });

    /* Hover Direction (Thumbnail)
    =========================================*/ 
    $('.hoverdir > li').each( function() { 
        $(this).hoverdir({
            hoverDelay : 75
        }); 
    });

    /* Portfolio Filter/Animation by Mixitup
    =========================================*/
    $('.projects').mixitup();

    /* Superslides
    =========================================*/
    $('#slides').superslides({
    	play: false,
    	animation_speed: 2000,
    	animation_easing: 'swing',
		animation: 'fade',
		inherit_width_from: $('#intro'),
	    inherit_height_from: window,
	    pagination: true,
	    hashchange: false,
	    scrollable: true	
    });

    /* Google Map
    =========================================
    $('#googlemap').gMap({
        maptype: 'ROADMAP',
        scrollwheel: false,
        zoom: 20,
        markers: [
            {
                address: '13/2 Elizabeth St, Melbourne VIC 3000, Australia', 
                html: '<p>Enter your text here</p>',
                popup: true,
            }
        ],
    });
    */

    /* Flickrfeed
    =========================================*/    
    $('.flickrfeed-view').jflickrfeed({
        limit: 8,
        qstrings: {
            id: '52617155@N08'
        },
        itemTemplate: '<li><a href="{{link}}"><img alt="{{title}}" src="{{image_s}}"></a></li>'
    });

    /* Ajax Contact Form
    =========================================*/ 
    $('#btn-contact').click(function(){
        var name = $('input[name=name]').val();
        var email = $('input[name=email]').val();
        var subject = $('input[name=subject]').val();
        var message = $('textarea[name=message]').val();

        var post_data = {'name':name, 'email':email, 'subject':subject, 'message':message};

        //Ajax post data to server
        $.post('process.php', post_data, function(data){  

        //load success massage in #result div element, with slide effect.      
        $("#result").hide().html('<div class="alert alert-success">'+data+'</div>').slideDown();

        //reset values in all input fields
        $('.contact-form input').val('');
        $('.contact-form textarea').val('');

        }).fail(function(err) {  //load any error data
            $("#result").hide().html('<div class="alert alert-danger">'+err.statusText+'</div>').slideDown();
        });
        return false;
    }); 
    
    /* --------------------------------------------------------------------------------------------- */
    /* Scrollup
    /* --------------------------------------------------------------------------------------------- */
   
	$(window).scroll(function(){
		if ($(this).scrollTop() > 600 ) {
			$('#scrollup').fadeIn();
		} else {
			$('#scrollup').fadeOut();
		}
	}); 
	
	$('.scrollup').click(function(){
		$("html, body").animate({ scrollTop: 0 }, 1000 , 'easeInOutExpo');
		return false;
	});
    // scrollup

})(jQuery);